//引入数据库
const mysql = require('mysql')
exports.base = (sql, data, callback) => {
//创建连接
    let dbconfig = require('../config/DB')
    const connection =mysql.createConnection(dbconfig.mysql)
//    开启连接
    connection.connect()
//  数据库操作
    connection.query(sql, data, (err, result) => {
    if(err) {
        console.log('ERR-', err.message)
    }
    callback(result)
    console.log('数据库连接成功')
    })
//    关闭数据库连接
    connection.end()
}
